OData result caching guidance 路 Issue #294 路 OData/AspNetCoreOData 路 GitHub 您所在的位置:网站首页 Caching guidance OData result caching guidance 路 Issue #294 路 OData/AspNetCoreOData 路 GitHub

OData result caching guidance 路 Issue #294 路 OData/AspNetCoreOData 路 GitHub

2023-08-05 22:06| 来源: 网络整理| 查看: 265

I'm trying to determine a strategy for caching of OData results. Typically with regular API controllers it's possible to utilize the IDistributedCache interface to do so just before returning the results, however since with OData controllers a queryable is being returned that is not the case.

I've had some luck in creating a resource filter attribute (IResourceFilter, Attribute) to intercept the result in the , eg:

public void OnResourceExecuted(ResourceExecutedContext context) { if (context.Result is not OkObjectResult result) return; var json = JsonSerializer.Serialize(result.Value); var cache = (IDistributedCache)context.HttpContext.RequestServices.GetService(typeof(IDistributedCache)); ...

However this fails on things like $count & $expand so I'm going to continue digging a bit. Just wondering though, is there any official guidance or plans on supporting caching in a similar manner? It'd be great if there was some sort of way to hook-in such functionality so that the existing IDistributedCache interface could be utilized in the correct manner. Thanks!



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有